using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace PrinterHack
{
    public partial class frmAdd : Form
    {
        private Form parentForm;

        public frmAdd()
        {
            InitializeComponent();
        }

        public frmAdd(Form ParentForm)
        {
            InitializeComponent();
            parentForm = ParentForm;
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                Printer printer = new Printer();
                printer.Name = txtName.Text;
                printer.IP = txtIP.Text;
                printer.Description = txtDescription.Text;
                printer.Save();
                frmMain parent = (frmMain)parentForm;
                parent.RefreshData();
                this.Close();
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

    }
}